<?php defined('ByShopWWI') or exit('Access Invalid!');?>

<div class="tabmenu">
  <?php include template('layout/submenu');?>
</div>
<form method="post" action="index.php" target="_self">
  <table class="search-form">
    <input type="hidden" name="act" value="menu_1018" />
    <input type="hidden" name="op" value="search" />
    <?php if ($_GET['state_type']) { ?>
      <input type="hidden" name="state_type" value="<?php echo $_GET['state_type']; ?>" />
    <?php } ?>
    <tr>
      <td>&nbsp;</td>
      <?php if ($_GET['state_type'] == 'menu_1018') { ?>
        <td><input type="checkbox" id="skip_off" value="1" <?php echo $_GET['skip_off'] == 1 ? 'checked="checked"' : null;?>  name="skip_off">
          <label for="skip_off">不显示已关闭的订单</label></td>
      <?php } ?>
      <th><?php echo $lang['store_order_buyer'];?></th>  <!-- 联系信息 -->
      <td class="w100"><input type="text" class="text w80" name="buyer" value="<?php echo $_GET['buyer']; ?>" /></td>
      <th><?php echo '电话';?></th>
      <td class="w160"><input type="text" class="text w150" name="phone" value="<?php echo $_GET['phone']; ?>" /></td>
      <td class="w70 tc"><label class="submit-border">
          <input type="submit" class="submit" value="<?php echo $lang['store_order_search'];?>" />  <!-- 搜索 -->
        </label></td>
    </tr>
  </table>
</form>
<table class="ncsc-default-table order">
  <thead>
  <tr>
    <th class="w10"></th>
    <th colspan="2"><?php echo $lang['store_order_goods_detail'];?></th>  <!-- 商品 -->
    <th class="w100"><?php echo $lang['store_order_goods_single_price'];?></th>  <!-- 单价 -->
    <th class="w40"><?php echo $lang['store_show_order_amount'];?></th>    <!-- 数量 -->
    <th class="w100"><?php echo $lang['store_order_buyer'];?></th>         <!-- 买家 -->
    <th class="w100"><?php echo $lang['store_order_sum'];?></th>   <!-- 订单金额 -->
    <th class="w90">交易状态</th>
    <th class="w120">交易操作</th>
  </tr>
  </thead>
  <?php if (is_array($output['order_list']) and !empty($output['order_list'])) { ?>
  <?php foreach($output['order_list'] as $order_id => $order) { ?>
  <tbody>
  <tr>
    <td colspan="20" class="sep-row"></td>
  </tr>
  <tr>                                          <!-- 订单编号 -->
    <th colspan="20"><span class="ml10"><?php echo $lang['store_order_order_sn'].$lang['nc_colon'];?><em><?php echo $order['id']; ?></em>
                            <!-- 下单时间 -->
        </span> <span><?php echo $lang['store_order_add_time'].$lang['nc_colon'];?><em class="goods-time"><?php echo date("Y-m-d H:i:s",$order['time']); ?></em></span>

      <span class="fr mr5"> <a href="index.php?act=store_order&op=order_print&order_id=<?php echo $order_id;?>" class="ncbtn-mini" target="_blank" title="打印发货单"/><i class="icon-print"></i>打印发货单</a></span> </th>
  </tr>

    <tr>
      <td class="bdl"></td>
      <td class="w70">
        <div class="ncsc-goods-thumb">
          <a href="<?php echo $goods['goods_url'];?>" target="_blank">
              <img src="<?php echo $order['image_60_url'];?>" onMouseOver="toolTip('<img src=<?php echo $order['image_60_url'];?>>')" onMouseOut="toolTip()"/>
          </a>
        </div>
      </td>
      <td class="tl">
        <dl class="goods-name">
          <dt>                                                           <!-- 商品名称 -->
            <a target="_blank" href="<?php echo $goods['goods_url'];?>"><?php echo $order['goods_name']; ?></a>

            <!--            <a target="_blank" class="blue ml5" href="--><?php //echo urlShop('snapshot', 'index', array('rec_id' => $goods['rec_id']));?><!--">-->
            <!--                [交易快照]-->
            <!--            </a>-->
          </dt>


          <!-- E消费者保障服务 -->
        </dl>
      </td>
      <td>
        <p>                          <!-- 价格显示 -->
          <?php echo ncPriceFormat($order['price']); ?>
        </p>
        <?php if (!empty($goods['goods_type_cn'])){ ?>
          <span class="sale-type"><?php echo $goods['goods_type_cn'];?></span>
        <?php } ?>
      </td>
      <td><?php echo $order['count']; ?></td>

      <!-- S 合并TD -->
      <?php if (($order['count'] > 1 && $k ==0) || ($order['count']) == 1){ ?>
        <td class="bdl" rowspan="1">    <!-- 改成 1 就好 -->
          <div class="buyer">
            <?php echo $order['buyer'];?>
            <p member_id="<?php echo $order['id'];?>">

              <!--
            <?php if(!empty($order['extend_member']['member_qq'])){?>
            <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=<?php echo $order['extend_member']['member_qq'];?>&site=qq&menu=yes" title="QQ: <?php echo $order['extend_member']['member_qq'];?>"><img border="0" src="http://wpa.qq.com/pa?p=2:<?php echo $order['extend_member']['member_qq'];?>:52" style=" vertical-align: middle;"/></a>
            <?php }?>


            <?php if(!empty($order['extend_member']['member_ww'])){?>
            <a target="_blank" href="http://amos.im.alisoft.com/msg.aw?v=2&uid=<?php echo $order['extend_member']['member_ww'];?>&site=cntaobao&s=2&charset=<?php echo CHARSET;?>" ><img border="0" src="http://amos.im.alisoft.com/online.aw?v=2&uid=<?php echo $order['extend_member']['member_ww'];?>&site=cntaobao&s=2&charset=<?php echo CHARSET;?>" alt="Wang Wang" style=" vertical-align: middle;" /></a>
            <?php }?>
          -->
            </p>
            <div class="buyer-info"> <em></em>
              <div class="con">
                <h3>
                  <i></i>
                  <span>            <!-- 联系信息 -->
                    <?php echo $lang['store_order_buyer_info'];?>
                </span>
                </h3>
                <dl>                    <!-- 姓名 -->
                  <dt><?php echo $lang['store_order_receiver'].$lang['nc_colon'];?></dt>
                  <dd><?php echo $order['buyer'];?></dd>
                </dl>
                <dl>                    <!-- 电话 -->
                  <dt><?php echo $lang['store_order_phone'].$lang['nc_colon'];?></dt>
                  <dd><?php echo $order['phone'];?></dd>
                </dl>
                <dl>
                  <dt>地址<?php echo $lang['nc_colon'];?></dt>
                  <dd><?php echo $order['extend_order_common']['reciver_info']['address'];?></dd>
                </dl>
              </div>
            </div>
          </div>
        </td>
        <td class="bdl" rowspan="1">
          <p class="ncsc-order-amount"><?php echo $order['price_sum']; ?></p>
          <p class="goods-freight">
            <?php if ($order['shipping_fee'] > 0){?>
              (含运费<?php echo $order['shipping_fee'];?>)
            <?php }else{?>
              <?php echo $lang['nc_common_shipping_free'];?>
            <?php }?>
          </p>                                         <!-- 支付方式 -->
          <p class="goods-pay" title="<?php echo $lang['store_order_pay_method'].$lang['nc_colon'];?>
                 <?php echo $order['payment_name']; ?>"><?php echo $order['payment_name']; ?>
          </p>
        </td>
        <td class="bdl bdr" rowspan="<?php echo $order['goods_count'];?>"><p><?php echo $order['state_desc']; ?>
            <?php if($order['evaluation_time']) { ?>
              <br/>
              <?php echo $lang['store_order_evaluated'];?>
            <?php } ?>
          </p>

          <!-- 订单查看 -->

          <p><a href="" >
              <?php
                    if($order['is_state']==0){
                          echo '待发货';
                    }else{
                          echo '已发货';
                    }
              ?>
            </a>
          </p>

          <!-- 物流跟踪 -->

          <p>
            <?php if ($order['if_deliver']) { ?>
              <a href='index.php?act=store_deliver&op=search_deliver&order_sn=<?php echo $order['order_sn']; ?>'><?php echo $lang['store_order_show_deliver'];?></a>
            <?php } ?>
          </p></td>

        <!-- 取消订单 -->
        <td class="bdl bdr" rowspan="1"><?php if(!$order['is_cancel']) { ?>
            <p>
              <a  name="index.php?act=menu_1018&op=cancel&id=<?php echo $order['id'] ?>"  class="ncbtn ncbtn-grapefruit mt5"

                 <i class="icon-remove-circle"></i>
                <?php echo $lang['store_order_cancel_order'];?></a>
            </p>
          <?php } ?>

          <!-- 修改运费价格 -->

          <?php if ($order['if_modify_price']) { ?>
            <p><a href="javascript:void(0)" class="ncbtn-mini ncbtn-bittersweet mt10" uri="index.php?act=store_order&op=change_state&state_type=modify_price&order_sn=<?php echo $order['order_sn']; ?>&order_id=<?php echo $order['order_id']; ?>" dialog_width="480" dialog_title="<?php echo $lang['store_order_modify_price'];?>" nc_type="dialog"  dialog_id="seller_order_adjust_fee" id="order<?php echo $order['order_id']; ?>_action_adjust_fee" /><i class="icon-pencil"></i>修改运费</a></p>
          <?php }?>
          <!--订单价格-->
          <?php if (!$order['is_cancel']) { ?>
            <p><a href="javascript:void(0)" class="ncbtn-mini ncbtn-bluejeansjeans mt10"
                  uri="index.php?act=menu_1018&op=order_change&id=<?php echo $order['id']; ?>"
                  dialog_width="480" dialog_title="<?php echo '修改订单';?>"
                  nc_type="dialog"  dialog_id="seller_order_adjust_fee" id="order<?php echo $order['order_id']; ?>_action_adjust_fee" />
                <i class="icon-pencil"></i>修改订单</a></p>
          <?php }?>

          <!-- 发货 -->

          <?php if ($order['if_store_send']) { ?>
            <p><a class="ncbtn ncbtn-mint mt10" href="index.php?act=store_deliver&op=send&order_id=<?php echo $order['order_id']; ?>"/><i class="icon-truck"></i><?php echo $lang['store_order_send'];?></a></p>
          <?php } ?>

          <!-- 锁定 -->

          <?php if ($order['if_lock']) {?>
            <p><?php echo '退款退货中';?></p>
          <?php }?>

        </td>

      <?php } ?>
      <!-- E 合并TD -->
    </tr>

    <!-- S 赠品列表 -->
    <?php if (!empty($order['zengpin_list']) && $i == count($order['goods_list'])) { ?>
      <tr>
        <td class="bdl"></td>
        <td colspan="4" class="tl"><div class="ncsc-goods-gift">赠品：
            <ul>
              <?php foreach ($order['zengpin_list'] as $zengpin_info) { ?>
              <li> <a title="赠品：<?php echo $zengpin_info['goods_name'];?> * <?php echo $zengpin_info['goods_num'];?>" href="<?php echo $zengpin_info['goods_url'];?>" target="_blank"><img src="<?php echo $zengpin_info['image_60_url'];?>" onMouseOver="toolTip('<img src=<?php echo $zengpin_info['image_240_url'];?>>')" onMouseOut="toolTip()"/></a></li>
            </ul>
            <?php } ?>
          </div></td>
      </tr>
    <?php } ?>
    <!-- E 赠品列表 -->

    <!-- S 预定时段 -->
    <?php if ($order['order_type'] == 2 && $i == count($order['goods_list'])) { ?>
      <?php if (is_array($order['book_list'])) { ?>
        <?php foreach($order['book_list'] as $book_info) {?>
          <tr>
            <td class="bdl"></td>
            <td colspan="2"><?php echo $book_info['book_step'];?></td>
            <td colspan="2"><?php echo $book_info['book_amount'].$book_info['book_amount_ext'];?></td>
            <td colspan="2"><?php echo $book_info['book_state'];?></td>
            <td class="bdr" colspan="2"></td>
          </tr>
        <?php } ?>
      <?php } ?>
    <?php } ?>
    <!-- E 预定时段 -->


  <?php } } else { ?>
    <tr>
      <td colspan="20" class="norecord"><div class="warning-option"><i class="icon-warning-sign"></i><span><?php echo $lang['no_record'];?></span></div></td>
    </tr>
  <?php } ?>
  </tbody>
  <tfoot>
  <?php if (is_array($output['order_list']) and !empty($output['order_list'])) { ?>
    <tr>
      <td colspan="20"><div class="pagination"><?php echo $output['show_page']; ?></div></td>
    </tr>
  <?php } ?>
  </tfoot>
</table>
<script charset="utf-8" type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/i18n/zh-CN.js" ></script>
<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css"  />
<script type="text/javascript">
  $(function(){
    $('#query_start_date').datepicker({dateFormat: 'yy-mm-dd'});
    $('#query_end_date').datepicker({dateFormat: 'yy-mm-dd'});
    $('.checkall_s').click(function(){
      var if_check = $(this).attr('checked');
      $('.checkitem').each(function(){
        if(!this.disabled)
        {
          $(this).attr('checked', if_check);
        }
      });
      $('.checkall_s').attr('checked', if_check);
    });
    $('#skip_off').click(function(){
      url = location.href.replace(/&skip_off=\d*/g,'');
      window.location.href = url + '&skip_off=' + ($('#skip_off').attr('checked') ? '1' : '0');
    });

    $("a").click(function(){
        var _url= $(this).attr("name");
        if(_url !== undefined){
           if(confirm('确定要取消此订单吗?'))
          {

                //Ajax调用处理
                $.ajax({
                    type: "POST",
                    url: _url,
                    data: "",
                    success: function(data){
                        window.location.reload();

                    }
                });

            return true;
          }else {
            return false;
          }

        }

    });


  });
</script> 
